$(function() {

		
	// 审核操作
	$("#btn_ok").click(function() {
		var url = rootPath + "/order/confirmVerifyOrder";
		var confirmType = $("#confirmType").val();
		
		var pass = $("#pass").is(':checked')?"01":"02";
		var approveReason = $("#approveReason").val();
		if(pass == "02" && $.trim(approveReason).length == 0){
			layer.alert('请录入核销不通过原因',{icon: 6});
			return false;
		}
		var params = {
			orderCode : $("#orderCode").val(),
			confirmType : $("#confirmType").val(),
			approveResult : pass,
			approveReason : approveReason
		};
		$.ajax({
	        type:"post",
	        url:url,
	        data:params,
	        datatype: "json",
	        success:function(json){
	        	if(json.resultCode == '1'){
	        		var index = parent.layer.getFrameIndex(window.name);
	        		parent.layer.alert('核销成功',{icon: 6});
	        		parent.layer.close(index);
	        		parent.location.href = rootPath + "/order/toOrderDetail?orderCode="+$("#orderCode").val()+"&tabIndex="+(json.confirmType=='1'?'2':'3');
	        	}else{
	        		layer.alert('核销失败',{icon: 6});
	        	}
	        },
	        error: function(){
	        	showErr("核销失败");
	        }
		});
	});
	
	
	$("#btn_back").click(function() {
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	});
	
	$("input[name='approveResult']").iCheck({
		checkboxClass: 'icheckbox_square-green',
	    radioClass: 'iradio_square-green',
	    increaseArea: '20%' // optional
	});
	
});

